package com.project.service.impl;

import com.project.bean.CarBean;
import com.project.mapper.ICarMapper;
import com.project.service.ICarService;
import org.apache.ibatis.session.SqlSession;

import java.util.List;
import java.util.ListResourceBundle;

public class CarServiceImpl extends BaseService implements ICarService {
    @Override
    public void addCar(CarBean carBean) {
        SqlSession session = this.getSession();
        ICarMapper mapper= session.getMapper(ICarMapper.class);
        mapper.addCar(carBean);
        session.commit();
        session.close();
    }

    @Override
    public List<CarBean> findAll() {
        SqlSession session = this.getSession();
        ICarMapper mapper= session.getMapper(ICarMapper.class);
        List<CarBean> list=mapper.findAll();
        session.close();
        return list;
    }

    @Override
    public CarBean findById(int carID) {
        SqlSession session = this.getSession();
        ICarMapper mapper=session.getMapper(ICarMapper.class);
        CarBean carBean = mapper.findById(carID);
        session.close();
        return carBean;
    }
}
